package edu.pitt.dbmi.monarch.rest;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.Response;
import java.util.HashMap;

/**
 * Author : Jeremy Espino MD
 * Created  9/10/13 5:16 PM
 */
@Path("/phenotype")
public class ToasterProxy extends AbstractRestService {

    @GET
    @Path("/{id}")
    public Response proxyize(@PathParam("id") String id) {

        ClientConfig cc = new DefaultClientConfig();
        Client client = Client.create(cc);

        WebResource service = client.resource(UriBuilder.fromUri("http://toaster.lbl.gov:8282/phenotype/" + id).build());

        String result = service.accept(MediaType.APPLICATION_JSON).get(String.class);

        return generateResponse(result);
    }


}
